#ifndef _SOCKET_H_
#define _SOCKET_H_

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#pragma once
#include "log\Log.h"
#include "ByteBuffer.h"
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iostream>
#include <sstream>
#include <string>
#include "NetworkException.h"

using namespace std;
using namespace logging;

namespace net
{
class Socket
{
public:
	Socket(void);
	virtual ~Socket(void);
	
	void setSocketConnection(SOCKET socket);
	SOCKET getSocketConnection();

	void doSendComplete(ByteBuffer* sendbuf);
	void doReceiveComplete(ByteBuffer* recvbuf);
	
	void doClose(void);
	void doShutdown();
	string toString(void);

	int doSend(const char* sendbuf);
	int doReceive(char* recvbuf, int recvbuflen);

protected:
	SOCKET socketConnection;
	struct addrinfo* obtainedAddress;
	struct addrinfo requestedAddress;
	static const int WSA_VERSION = 2;
	static const int WSA_REVISION = 2;
};
};
#endif
